from apps.course.models import Course
from apps.participants.models import CourseParticipant
from django.core.urlresolvers import resolve
from views import manage
from apps.management import Management

def management(request):
    #Does this user have anything to manage?
    ReturnDict = {}
    CourseUser = {'is_management':False,'course_participant':None}
    TheCourse = Course.RequestCourse(request)
        
    if request.user.is_superuser:
        CourseUser['is_management'] = True
    if TheCourse:
        TheUser = request.user
        if TheUser and TheUser.is_authenticated():
            TheCourseParticipant = CourseParticipant.find(TheCourse.course_id,user=TheUser)
            if TheCourseParticipant:
                CourseUser['course_participant'] = TheCourseParticipant
                if (TheCourseParticipant.status == "INSTRUCTOR" or TheCourseParticipant.status == "ASSISTANT"):
                    CourseUser['is_management'] = True
    ReturnDict['CourseUser'] = CourseUser
    return ReturnDict